package util
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLRequest;

	public class ImageLoader
	{
		public function ImageLoader() {}
		
		public static function load(path):Bitmap {
			
			var loader:Loader = new Loader();
			try
			{
				loader.load(new URLRequest("path to image"));
			}
			catch(e:Error){}
			//.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, io, false, 0, true);
			//loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress, false, 0, true);
			//loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded, false, 0, true);
		}
		
//		private function loadImage():void
//		{
//			
//		}
//		
//		private function loadProgress(e:ProgressEvent):void
//		{
//			var percent:String = Math.round(e.bytesLoaded / e.bytesTotal) * 100 + "% loaded";
//			trace(percent);
//		}
//		
//		private function imageLoaded(e:Event):void
//		{
//			e.currentTarget.removeEventListener(IOErrorEvent.IO_ERROR, io);
//			e.currentTarget.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
//			e.currentTarget.removeEventListener(Event.COMPLETE, imageLoaded);
//			
//			var image:Bitmap = e.target.content as Bitmap;
//			addChild(image);
//		}
//		
//		private function io(e:IOErrorEvent):void{}
	}
}